package cn.cas.mango.util.paramCheck;

import cn.cas.mango.dto.param.QueryParam;
import cn.cas.mango.dto.param.TopicParam;
import org.apache.logging.log4j.util.Strings;

import java.util.HashMap;
import java.util.Map;

import static cn.cas.mango.util.paramCheck.ParamCheckUtil.string2FieldValue;

public class TopicParamCheckUtil {
  public static Map<String, Object> checkParam(TopicParam formData) {
    String isSuccess = "ok";
    if (Strings.isBlank(formData.getTopicNm())) {
      return new HashMap<String,Object >(){{put("isSuccess", "topicParam 为空");}};
    }
    if (formData.getCurrentPage() == null || formData.getCurrentPage() < 1) {
      formData.setCurrentPage(1);
    }
    if (formData.getPageSize() == null || formData.getPageSize() < 0) {
      formData.setPageSize(20);
    }

    if (formData.getOrder() == null) {
      formData.setOrder("time");
    }
    Map<String, Object> map = new HashMap<>();
    map.put("isSuccess", isSuccess);
    map.put("formData", formData);
    return map;
  }
}
